<?php
require_once dirname(__FILE__).'/../../../../bootstrap/unit.php';

class unit_OrganizationalUnitPropertyRecipientDeterminationRuleTest extends WildlivePHPUnitTestCase
{
  public function testExistingOrgUnitChairman()
  {
    $unit = $this->getStammSilvaAbnoba();
    $rule = new OrganizationalUnitPropertyRecipientDeterminationRule($unit, 'org_unit_chairman');
    $this->assertEquals(205, $rule->doCalculate());
  }

  public function testNotExistingOrgUnitDeputyChairman ()
  {
    $unit = $this->getStammSilvaAbnoba();
    $rule = new OrganizationalUnitPropertyRecipientDeterminationRule($unit, 'org_unit_deputy_chairman');
    $this->assertNull($rule->doCalculate());
  }

  public function testExistingOrgUnitTreasurer ()
  {
    $unit = $this->getStammSilvaAbnoba();
    $rule = new OrganizationalUnitPropertyRecipientDeterminationRule($unit, 'org_unit_treasurer');
    $this->assertEquals(64, $rule->doCalculate());
  }
  
  
  /**
   * @return OrganizationalUnit
   */
  private function getStammSilvaAbnoba() {
    $unit = OrganizationalUnitTable::getInstance()->findOneByName('Stamm Silva Abnoba');
    $this->assertInstanceOf('OrganizationalUnit', $unit, 'Check fixtures');
    return $unit;
  }
}